


new Vue({
    el: '#app',
    data: function () {
        return {
            visible: false,
            searchVal: '',
            tableData: [],
            tagOne: true,
            tagTwo: false,
            historyArr: []
        }
    },
    methods: {
        searchGo: function () {

            var curVue = this;

            var param = {
                searchKey: this.searchVal
            };

            if (_.trim(this.searchVal) != "") {

                var orignStr = localStorage.getItem("keywords");
                var orignArr = orignStr.split("$$") || [];


                if (orignArr.indexOf(this.searchVal) == -1) {
                    if (orignArr.length >= 5) {
                        orignArr = orignArr.slice(orignArr.length - 5, orignArr.length);
                    }

                    orignArr.push(this.searchVal);
                }


                localStorage.setItem("keywords", orignArr.join("$$"));

                curVue.historyArr = orignArr;

                var url = "http://192.168.101.178:8100/solr/my_solr/select?indent=on&q=text:*&wt=json";
                $.ajax({
                    url: url,
                    success: function (data) {
                        curVue.tableData = data.response.docs;
                    }
                })
            }




        },
        tagClose: function () {
            alert(1);
        },
        toggleCategory: function (key) {
            this[key] = !this[key];
        },
        clearHistory: function () {
            localStorage.setItem("keywords", "");
            this.historyArr = [];
        },
        historyBtnClick: function (h) {
            this.searchVal = h;
            this.searchGo();
        }
    }
})